<template>
	<div>
		<el-card
			v-loading="loading"
			element-loading-text="拼命加载中"
			element-loading-spinner="el-icon-loading"
			element-loading-background="rgba(0, 0, 0, 0.8)"
		>
			<template #header style="padding:0;">
				<div class="bc" style="height: 200px;">
					<div class="zp">
            <el-avatar :size="140" src="https://empty" @error="errorHandler">
							<img :src= StaffArchives.staffImages />
						</el-avatar>
					</div>
          <div class="js" style="top:22px;line-height:22px;color:#FFFFFF;" ><br/>
            <p style="font-size:14pt;">{{ StaffArchives.staffName }} </p><br/>
            <p>部门：{{ StaffArchives.staffDepartment }}</p>
            <p>职务：{{ StaffArchives.staffJob }} </p>
            <p>入职日期：{{ StaffArchives.staffWorkindate }}</p>
             <p>工龄：{{ StaffArchives.staffWorktime }}</p>
					</div>
				</div>
			</template>
			<div>
				<el-tabs type="border-card" style="width: 90%; margin-left: 5%">
					<el-tab-pane>
						<template #label>
							<span><i class="el-icon-date"></i> 基本信息</span>
						</template>
						<Information v-if="StaffArchives != ''"/>
						<div v-else class="filtering-no-data">
							<div class="no-data-box">
								<el-empty description="暂无数据" :image-size="200"></el-empty>
							</div>
						</div>
					</el-tab-pane>
					<el-tab-pane>
						<template #label>
							<span><i class="el-icon-date"></i> 教育经历</span>
						</template>
						<Education v-if="StaffArchives != ''"/>
						<div v-else class="filtering-no-data">
							<div class="no-data-box">
								<el-empty :image-size="200"></el-empty>
							</div>
						</div>
					</el-tab-pane>
					<el-tab-pane>
						<template #label>
							<span><i class="el-icon-guide"></i> 工作经历</span>
						</template>
						<Work v-if="StaffArchives != ''"/>
						<div v-else class="filtering-no-data">
							<div class="no-data-box">
								<el-empty :image-size="200"></el-empty>
							</div>
						</div>
					</el-tab-pane>
					<el-tab-pane>
						<template #label>
							<span><i class="el-icon-collection"></i> 员工证书</span>
						</template>
						<Certificate v-if="StaffArchives != ''"/>
						<div v-else class="filtering-no-data">
							<div class="no-data-box">
								<el-empty :image-size="200"></el-empty>
							</div>
						</div>
					</el-tab-pane>
				</el-tabs>
				<div width="100%" height="50px" line-height="50px" align="center" style="margin:10px 0 0 0 ">
					<el-button type="primary" icon="el-icon-message" round @click='open'>发送Office</el-button>
					<el-button type="success" icon="el-icon-check" round @click='open2'>申请访问权限</el-button>
				</div>
			</div>
		</el-card>

	</div>
</template>
<script lang="ts">
import Information from '/@/views/talent_pool/details/component/information.vue';
import Education from '/@/views/talent_pool/details/component/Education.vue';
import Work from '/@/views/talent_pool/details/component/Work.vue';
import Certificate from '/@/views/talent_pool/details/component/Certificate.vue';
import Welfare from '/@/views/talent_pool/details/component/Welfare.vue';
import Salary from '/@/views/talent_pool/details/component/Salary.vue';
import Grow from '/@/views/talent_pool/details/component/Grow.vue';
import { toRefs, reactive } from 'vue';
import axios from 'axios';
export default {
	components: { Information, Education, Work, Welfare,Certificate,Salary,Grow},
	name: 'Personal_archives',
	setup() {
		const state = reactive({
			form: {},
		});
		return {
			...toRefs(state),
		};
	},
	data() {
		return {
			StaffArchives: '',
			loading: true,
		};
	},
	created() {
		setInterval(() => {
			var that = this;
			axios.get('http://121.41.117.22:8081/staff-archives/staffid=' + that.$route.query.id)
				.then(function (response) {
					that.StaffArchives = response.data[0];
				})
				.catch(function (err) {});
				that.loading = false;
			}, 1300)
	},
	methods: {
		open() {
			this.$confirm('是否向该用户发送Office通知', '提示', {
				confirmButtonText: '发送',
				cancelButtonText: '取消',
				type: 'warning',
				center: true
			}).then(() => {
				this.$message({
					type: 'success',
					message: '发送成功!'
				});
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '取消'
				});
			});
		},
		open2() {
			this.$confirm('向该用户申请访问权限', '确认信息', {
				distinguishCancelAndClose: true,
				confirmButtonText: '确定',
				cancelButtonText: '放弃'
			})
				.then(() => {
					this.$message({
						type: 'success',
						message: '发送成功！'
					});
				})
				.catch(action => {
					this.$message({
						type: 'info',
						message: action === 'cancel'
							? '放弃'
							: '停留在当前页面'
					})
				});
		},
	},
};
</script>
<style lang="scss">
.bc{
	position: relative;
};
.zp{
  top:35px;
  position: absolute;
  left: 12%;
}
.js{
  position: absolute;
  left: 25%;
  color: gray;
}
.bc{
  background-color: red; /* 浏览器不支持时显示 */
  background: linear-gradient(to right,#4facfb 0%, #00f2fe 100%);
}
</style>
